{include file="public/layout.htm" /}
<script type="text/javascript" src="__SKIN__/js/clipboard.min.js"></script>
<body class="back-c">
    <div class="ey-content">
        <div class="mescroll-ey-warp list-wrap" >
            <div class="mescroll-ey mescroll-ey-fixed list-prc">
                <div class="ey-scroll-view">
                    <div class="ey-scroll-view-content">
                        <div class="mescroll-ey-content">
                            <form class="form-horizontal" id="goodsPost">
                                <input type="hidden" name="aid" value="{$goods.aid}">
                                <input type="hidden" name="openSpec" value="{$openSpec}">
                                <div class="sku-list">
                                    {empty name="$htmlTable"}
                                    <div class="item-wrap">
                                        <div class="order-list">
                                            <div class="list-left">销售价</div>
                                            <div class="list-right">
                                                <div class="ey-input">
                                                    <div class="ey-input-wrapper">
                                                        <div class="text">{$goods.users_price}</div>
                                                        <span class="t">元</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="order-list">
                                            <div class="list-left">库存<em class="color-red-text">*</em></div>
                                            <div class="list-right">
                                                <div class="ey-input">
                                                    <div class="ey-input-wrapper">
                                                        <input class="ey-input-input" type="text" name="stock_count" id="stock_count" value="{$goods.stock_count}" onkeyup="this.value=this.value.replace(/[^\d]/g,'');" onpaste="this.value=this.value.replace(/[^\d]/g,'');">
                                                        <span class="t">件</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    {else/}
                                    {$htmlTable}
                                    {/empty}
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="blank-big"></div>
        <div class="w100-footer-wrap fixed-footer-wrap">
            <button class="w50-btn-no" onclick="window.history.back();">返回</button>
            <button class="w50-btn" onclick="saveGoods();">保存</button>
        </div>
    </div>
    <script type="text/javascript">
        function saveGoods() {
            layerLoading('正在处理');
            $.ajax({
                type: "POST",
                url : "{:weapp_url('Mbackend/ShopProduct/goods_quick_edit', ['_ajax'=>1])}",
                data: $('#goodsPost').serialize(),
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if (1 === parseInt(res.code)) {
                        layerMsg(res.msg, 1, function() {
                            // 返回上一页
                            window.history.back();

                            // 刷新页面
                            setTimeout(function() {
                                location.reload();
                            }, 100); // 设置延时是因为有些浏览器可能会阻止在短时间内连续执行后退和刷新操作
                        });
                    } else {
                        layerAlert(res.msg);
                    }
                },
                error: function(e) {
                    layer.closeAll();
                    layerAlert(e.responseText);
                }
            });
        }
    </script>
    <script type="text/javascript" src="__WEAPP_TEMPLATE__/skin/js/shop_product.js?v={$weappInfo.version|default='v1.0.0'}"></script>
</body>
{include file="public/footer.htm" /}